package stark.app.function.shortcut;

import android.content.pm.PackageInfo;
import android.graphics.drawable.Drawable;

import com.blankj.utilcode.util.AppUtils;
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder;

import org.jetbrains.annotations.NotNull;

import stark.app.R;
import stark.app.databinding.ItemStPckInfoBinding;
import stark.common.basic.adapter.BaseDBRVAdapter;

/**
 * Author：daizhongbin on 2021/8/20
 * Email：1027154338@qq.com
 * Desc:
 */
public class StPackageAdapter extends BaseDBRVAdapter<PackageInfo, ItemStPckInfoBinding> {

    public StPackageAdapter() {
        super(R.layout.item_st_pck_info, 0);
    }

    @Override
    protected void convert(@NotNull BaseDataBindingHolder<ItemStPckInfoBinding> holder, PackageInfo packageInfo) {
        ItemStPckInfoBinding binding = holder.getDataBinding();
        Drawable drawable = AppUtils.getAppIcon(packageInfo.packageName);
        binding.ivIcon.setImageDrawable(drawable);

        CharSequence label = AppUtils.getAppName(packageInfo.packageName);
        binding.tvLabel.setText(label);
    }
}
